//
//  ViewController.m
//  18---SQLite
//
//  Created by 冀永金 on 16/8/8.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "ViewController.h"
#import "SQLiteDataBaseManager.h"
#import "Student.h"
@interface ViewController ()
@property (nonatomic, strong) SQLiteDataBaseManager *dataBaseManager;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _dataBaseManager = [SQLiteDataBaseManager shareManager];
//   int a,*pa;
//    a=10;
//    pa=&a;
//    *pa=20;
//  NSLog(@"____________%d", a);
    // SQLite3
    // 注意：使用SQLite需要引入libsqlite3.0.tbd
    //libsqlite3.0.tbd  libsqlite3.tbd
    // libsqlite3.0.tbd是libsqlite3.tbd的替身文件， 防止用户误删
    // Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)openSQLite:(id)sender {
    [_dataBaseManager openSQLite3];
    
}
- (IBAction)closeSQLite:(id)sender {
    [_dataBaseManager closeSQLite3];
}
- (IBAction)createTable:(id)sender {
    [_dataBaseManager createTable];
}
- (IBAction)insertStudent:(id)sender {
    Student *stu = [[Student alloc]init];
    stu.name = @"小明";
   // stu.name = @"小刚";
    [_dataBaseManager insertStu:stu];
}
- (IBAction)deleteStu:(id)sender {
   //[_dataBaseManager deleteStu:8];
    
    [_dataBaseManager deleteAll];
}
- (IBAction)updateStuent:(id)sender {
    Student *stu = [[Student alloc]init];
    stu.name = @"小红";

    [_dataBaseManager updateStudent:stu forId:8];
}
- (IBAction)selectStudent:(id)sender {
    NSMutableArray *marr =[_dataBaseManager slecteAll];
    NSLog(@"%@",marr);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
